Skip to content

feat(desktop): the update button rebuilds a local build from its checkout - #290

Open
mleungdev wants to merge 1 commit into
mainfrom
feat/desktop-source-updates
Open

mleungdev wants to merge 1 commit into
mainfrom
feat/desktop-source-updates

Conversation

@mleungdev

Copy link
Copy Markdown

Problem

A desktop app built from a git checkout has no working update path. The updater looks for a release feed that a local build does not have, so "Check for Updates" does nothing useful. People who run the fork from source rebuild and reinstall by hand, and the macOS build command was not written down anywhere, so some of us started the app with a mise command every time instead.

Fix

The build can write a source-update.json into the app's resources (T3CODE_DESKTOP_SOURCE_UPDATE_CONFIG=<file> when running dist:desktop:dmg). When that file is present:

  • "Check for Updates" asks scripts/source-update.ts in the checkout whether the configured remote branch (default origin/main) has commits the app was not built from. If it does, the app shows an update with the version it would build and the incoming commit subjects as notes.
  • "Update" fetches, rebases the checkout onto the new commits, rebuilds the app, runs the configured verify commands on the staged bundle, and on restart swaps the installed app in place (the old one goes to a backup folder).
  • The update refuses to run on a dirty checkout, when the incoming commits touch a configured review path, or when the rebase does not apply cleanly.
  • The copy names the source when the config has a label, as in "Check for Trogon fork Updates", "Update Trogon fork" and "T3 Code 0.1.13-source… (Trogon fork)" in the update-everything dialog. A failed in-app update shows a dialog with the reason.
  • The release notes list the incoming commit subjects, and "View commit … on GitHub" links to the target commit on the remote's forge instead of a release tag that does not exist.

Versions of such builds look like 0.1.13-source.20261204.17163 (base version, UTC day of the commit, commit count), which keeps them on the stable channel and sorts them.

All of the logic lives in new files (packages/shared/src/sourceUpdate.ts, scripts/source-update.ts, scripts/lib/source-update-build.ts, apps/desktop/src/electron/SourceUpdater.ts). Upstream files only gain an import and a call each, so merging upstream stays easy. Without the config file nothing changes: the desktop keeps using ElectronUpdater as before.

docs/operations/00_development.md now has the macOS build and install commands and the source-update setup. docs/fork/0051 records the decision.

Testing

  • Unit tests: shared (2), scripts with real temp git repos (5), desktop updater with a fake host (6), web label helper and menu tests.
  • End to end on macOS: built the app with a config and installed it, pointed the checkout at a local clone with one extra commit on main, checked for updates from the menu, pressed Update, watched the rebuild and verify steps run, and restarted into the rebuilt app. The review-path refusal and its dialog were exercised the same way.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@mleungdev
mleungdev force-pushed the feat/desktop-source-updates branch from 406d828 to 8fd1e45 Compare December 5, 2026 02:29
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XXL 1,000+ effective changed lines (test files excluded in mixed PRs). labels Dec 5, 2026
…kout

A desktop app built from a git checkout had no working update path. The
updater looked for a release feed that a local build does not have, so
"Check for Updates" did nothing useful and people rebuilt by hand.

The build can now write a `source-update.json` into the app's resources.
When that file is present, the desktop updater asks `scripts/source-update.ts`
in the checkout whether the configured remote branch has new commits. If it
does, the update button fetches, rebases the checkout onto them, rebuilds the
app, runs the configured verify commands on the staged bundle, and swaps the
installed app on restart. The copy says which source it updates from when the
config names one, as in "Check for Trogon fork Updates".

All of the logic lives in new files; the upstream files only gain a small
import and a call each, so merging upstream stays easy. The development doc
gains the macOS build and install commands and the source-update setup.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Mike Leung <2996848+mleungdev@users.noreply.github.com>
@mleungdev
mleungdev force-pushed the feat/desktop-source-updates branch from 8fd1e45 to 9286d53 Compare December 5, 2026 02:32
@github-actions

github-actions Bot commented Dec 5, 2026

Copy link
Copy Markdown

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.5 KiB 92.5 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 78.3 KiB 78.3 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 75 75 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 79.2 KiB 79.2 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 75 75 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: 9051ae1 · PR result: 9286d53 · Source CI: failure

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No blocking issues — two non-blocking findings below.

Approach: sound — the implementation provides a drop-in ElectronUpdater.Service alternative that swaps in only when source-update.json is present, keeping upstream merges trivial.

Reviewed changes:

  • Core update flow — SourceUpdater.ts mirrors the existing ElectronUpdater service contract (check, download, quit-and-install, events) while delegating to the checkout's source-update.ts script; no behavioral change without the config.
  • Script engine — scripts/source-update.ts handles four subcommands (describe, update, build, install) via JSON-lines stdout; clean separation of concerns and solid error reporting.
  • Build integration — scripts/lib/source-update-build.ts stages the config and a dummy app-update.yml when T3CODE_DESKTOP_SOURCE_UPDATE_CONFIG is set; scripts/build-desktop-artifact.ts gates it behind a flag.
  • Contracts & web UI — ipc.ts adds an optional url field to DesktopUpdateReleaseNote; web components surface the source label in menus, buttons, tooltips, and the update-everything dialog.
  • i18n — new msg templates with {{label}} interpolation across all 13 translation files for desktop and web.
  • Tests — SourceUpdater.test.ts (6), source-update.test.ts (5), and sourceUpdate.test.ts (3) cover the happy paths, error handling, dirty-check, review-path refusal, and the install-with-relaunch flow.

The @effect-diagnostics suppression was missing from sourceUpdate.test.ts — that was fixed inline (no diagnostic context change).

Non-blocking

  • Rebase has no progress indication. The rebase command at scripts/source-update.ts:281 can take a long time (full fetch + apply) but the progress bar stays at 10% with no feedback, which may confuse users into thinking the update hung. Consider emitting periodic progress ticks or at least logging the step in the progress stream before and after the git call.
  • Stderr is truncated to 4000 chars. The SourceUpdater.run handler at apps/desktop/src/electron/SourceUpdater.ts:334 drops earlier stderr output with .slice(-4000). Non-JSON error lines are rare since scripts typically emit JSON error messages, but in the fallback path the truncated tail is concatenated with the exit-code message, which could lose diagnostic context.

Pullfrog  | Fix it ➔ | View workflow run | Using qwen3.6-35b-a3b | 𝕏

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ effective changed lines (test files excluded in mixed PRs). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant